﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style x:Key="{x:Type Menu}" TargetType="{x:Type Menu}">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="VerticalAlignment" Value="Stretch"></Setter>
        
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Menu}">
                    <StackPanel ClipToBounds="True" Orientation="Horizontal" IsItemsHost="True" Margin="{TemplateBinding Margin}" VerticalAlignment="{TemplateBinding VerticalAlignment}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}">
        <Setter Property="Height" Value="1" />
        <Setter Property="Margin" Value="0" />
        <Setter Property="SnapsToDevicePixels" Value="True"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Separator}">
                    <Border BorderThickness="0 1 0 0" SnapsToDevicePixels="True">
                        <Border.BorderBrush>
                            <SolidColorBrush Color="#FF444444" />
                        </Border.BorderBrush>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="Button" x:Key="ErrorButton">
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Height" Value="17"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="FontSize" Value="10"/>
        <Setter Property="Foreground" Value="#FFAA0000"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border  x:Name="Border" CornerRadius="3" BorderThickness="1" Background="Transparent" BorderBrush="#FFAA0000" Opacity=".6" Padding="2 0 2 0" Height="17">
                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" RecognizesAccessKey="True" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Border" Property="BorderBrush" Value="#FFAA0000" />
                            <Setter TargetName="Border" Property="Opacity" Value="1" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="#FFFFAAAA" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="#FFAA0000" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- TopLevelHeader -->
    <ControlTemplate x:Key="{x:Static MenuItem.TopLevelHeaderTemplateKey}" TargetType="{x:Type MenuItem}">
        <Border x:Name="Border" Background="Transparent" BorderBrush="Transparent" CornerRadius="3" BorderThickness="1">
            <Grid>
                <ContentPresenter ContentSource="Header" RecognizesAccessKey="True" Margin="5 0 5 1" VerticalAlignment="Center" />
                <Popup x:Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsSubmenuOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Slide" Margin="0" VerticalOffset="6">
                    <Border x:Name="SubmenuBorder" SnapsToDevicePixels="True" BorderThickness="1" Background="#EEFFFFFF" CornerRadius="3" Padding="0 0 0 0" BorderBrush="#FF444444" Margin="0">
                        <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"/>
                    </Border>
                </Popup>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsSuspendingPopupAnimation" Value="true">
                <Setter TargetName="Popup" Property="PopupAnimation" Value="None" />
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter TargetName="Border" Property="BorderBrush" Value="#FF444444" />
                <Setter Property="Background" TargetName="Border" Value="#CCFFFFFF"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground">
                    <Setter.Value>
                        <SolidColorBrush Color="#FFBBBBBB" />
                    </Setter.Value>
                </Setter>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- TopLevelItem -->
    <ControlTemplate x:Key="{x:Static MenuItem.TopLevelItemTemplateKey}" TargetType="{x:Type MenuItem}">
        <Border x:Name="Border">
            <Grid>
                <ContentPresenter Margin="5 0 5 1" ContentSource="Header" RecognizesAccessKey="True" VerticalAlignment="Center" />
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter Property="Background" TargetName="Border" Value="#FF5787b6" />
                <Setter Property="Foreground">
                    <Setter.Value>
                        <SolidColorBrush Color="#FFFFFFFF" />
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="IsHighlighted" Value="false">
                <Setter Property="Foreground">
                    <Setter.Value>
                        <SolidColorBrush Color="#FF000000" />
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground">
                    <Setter.Value>
                        <SolidColorBrush Color="#FFBBBBBB" />
                    </Setter.Value>
                </Setter>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- SubmenuItem -->
    <ControlTemplate x:Key="{x:Static MenuItem.SubmenuItemTemplateKey}" TargetType="{x:Type MenuItem}">
        <Border x:Name="Border" BorderThickness="0" Padding="0 4 0 4">
            <Grid Margin="0 0 0 0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="Icon" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut" />
                    <ColumnDefinition Width="13" />
                </Grid.ColumnDefinitions>
                <ContentPresenter x:Name="Icon" Margin="6,0,6,0" VerticalAlignment="Center" ContentSource="Icon" />
                <Grid x:Name="CheckMarkGrid" Width="13" Height="13" Margin="10 0 10 0" Visibility="Collapsed" VerticalAlignment="Center">
                    <Ellipse x:Name="CheckMark" StrokeThickness="1" Stroke="#FF444444" Fill="#FFBAD0F0" Visibility="Collapsed">
                    </Ellipse>
                    <Ellipse x:Name="UnCheckedMark" StrokeThickness="1" Stroke="#FF999999" Fill="#FFFFFFFF">
                    </Ellipse>
                </Grid>
                <ContentPresenter x:Name="HeaderHost" Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True" VerticalAlignment="Center" />
                <TextBlock x:Name="InputGestureText" Grid.Column="2" Text="{TemplateBinding InputGestureText}" Margin="5,0,0,0" />
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="ButtonBase.Command" Value="{x:Null}" />
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter TargetName="Icon" Property="Visibility" Value="Hidden" />
            </Trigger>
            <Trigger Property="IsCheckable" Value="true">
                <Setter TargetName="CheckMarkGrid" Property="Visibility" Value="Visible" />
                <Setter TargetName="Icon" Property="Visibility" Value="Hidden" />
            </Trigger>
            <Trigger Property="IsCheckable" Value="false">
                <Setter TargetName="CheckMarkGrid" Property="Visibility" Value="Collapsed" />
                <Setter TargetName="Icon" Property="Visibility" Value="Hidden" />
            </Trigger>
            <Trigger Property="IsChecked" Value="true">
                <Setter TargetName="CheckMark" Property="Visibility" Value="Visible" />
                <Setter TargetName="UnCheckedMark" Property="Visibility" Value="Collapsed" />
                <Setter TargetName="CheckMarkGrid" Property="Visibility" Value="Visible" />
                <Setter TargetName="Icon" Property="Visibility" Value="Hidden" />
            </Trigger>
            <Trigger Property="IsPressed" Value="true">
                <Setter TargetName="CheckMark" Property="Stroke" Value="#FF222222" />
                <Setter TargetName="UnCheckedMark" Property="Stroke" Value="#FF444444" />
                <Setter TargetName="CheckMark" Property="Fill" Value="#FF4986c0" />
                <Setter TargetName="UnCheckedMark" Property="Fill" Value="#FF4986c0" />
            </Trigger>
            <Trigger Property="IsHighlighted" Value="false">
                <Setter Property="Foreground">
                    <Setter.Value>
                        <SolidColorBrush Color="#FF000000" />
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter TargetName="CheckMark" Property="Stroke" Value="#FF444444" />
                <Setter Property="Background" TargetName="Border" Value="#FF4e8ac4" />
                <Setter Property="Foreground">
                    <Setter.Value>
                        <SolidColorBrush Color="#FFFFFFFF" />
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground">
                    <Setter.Value>
                        <SolidColorBrush Color="#FFBBBBBB" />
                    </Setter.Value>
                </Setter>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="{x:Static MenuItem.SubmenuHeaderTemplateKey}" TargetType="{x:Type MenuItem}">
        <Border x:Name="Border" BorderThickness="0" Padding="0 4 0 4">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"  SharedSizeGroup="Icon" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut" />
                    <ColumnDefinition Width="13" />
                </Grid.ColumnDefinitions>
                <ContentPresenter x:Name="Icon" Margin="6,0,6,0" VerticalAlignment="Center" ContentSource="Icon" />
                <ContentPresenter x:Name="HeaderHost" Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True" VerticalAlignment="Center" />
                <TextBlock x:Name="InputGestureText" Grid.Column="2" Text="{TemplateBinding InputGestureText}" Margin="5,0,0,0" />
                <Path x:Name="Arrow" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" Data="M 0 0 L 0 7 L 4 3.5 Z" Fill="#FF444444"/>
                <Popup x:Name="Popup" Placement="Right" HorizontalOffset="4" IsOpen="{TemplateBinding IsSubmenuOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Scroll">
                    <Border x:Name="SubmenuBorder" SnapsToDevicePixels="True" Background="#EEFFFFFF" BorderThickness="1" CornerRadius="3" Padding="0" BorderBrush="#FF444444" Margin="0">
                        <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
                    </Border>
                </Popup>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter TargetName="Icon" Property="Visibility" Value="Hidden" />
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter TargetName="Arrow" Property="Fill" Value="#FFFFFFFF" />
                <Setter Property="Background" TargetName="Border" Value="#FF4e8ac4" />
                <Setter Property="Foreground">
                    <Setter.Value>
                        <SolidColorBrush Color="#FFFFFFFF" />
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="IsHighlighted" Value="false">
                <Setter Property="Foreground">
                    <Setter.Value>
                        <SolidColorBrush Color="#FF000000" />
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground">
                    <Setter.Value>
                        <SolidColorBrush Color="#FFBBBBBB" />
                    </Setter.Value>
                </Setter>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- MenuItem Style -->
    <Style x:Key="{x:Type MenuItem}" TargetType="{x:Type MenuItem}">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Style.Triggers>
            <Trigger Property="Role" Value="TopLevelHeader">
                <Setter Property="Template" Value="{StaticResource {x:Static MenuItem.TopLevelHeaderTemplateKey}}" />
                <Setter Property="Grid.IsSharedSizeScope" Value="true" />
            </Trigger>
            <Trigger Property="Role" Value="TopLevelItem">
                <Setter Property="Template" Value="{StaticResource {x:Static MenuItem.TopLevelItemTemplateKey}}" />
            </Trigger>
            <Trigger Property="Role" Value="SubmenuHeader">
                <Setter Property="Template" Value="{StaticResource {x:Static MenuItem.SubmenuHeaderTemplateKey}}" />
            </Trigger>
            <Trigger Property="Role" Value="SubmenuItem">
                <Setter Property="Template" Value="{StaticResource {x:Static MenuItem.SubmenuItemTemplateKey}}" />
            </Trigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>